<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link href="${ctxPath!}/layui/css/layui.css" rel="stylesheet" type="text/css">
    <% include("/templates/common/dialog.html"){} %>
</head>
<body>
<div style="padding:10px 50px 10px 10px">
    <form id="receiptForm" method="post" action="${ctxPath!}/sys/receipt/edit" class="layui-form">
        <div style="margin-bottom:20px;font-size:14px;border-bottom:1px solid #ccc; padding-bottom: 5px;">收款信息</div>
        <input type="hidden" name="id" value="${receipt.id}"/>
        <div class="layui-form-item">
            <label class="layui-form-label">客户姓名</label>
            <div class="layui-input-block">
                <select name="contractId" id="contractId">
                    <option value=""></option>
                    <%
                    for(contract in contracts!){
                    %>
                    <option value="${contract.id}" ${receipt.contractId == contract.id ? "selected" : ""}>${contract.userName}</option>
                    <%
                    }
                    %>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">收款时间</label>
            <div class="layui-input-block">
                <input class="layui-input" type="text" name="receiptDate" id="receiptDate" value="${receipt.receiptDate!,dateFormat="yyyy-MM-dd"}"  lay-verify="required|date" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">合同金额</label>
            <div class="layui-input-block">
                <input class="layui-input" type="text" name="contractMoney" value="${receipt.contractMoney!}" lay-verify="required" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">收款金额</label>
            <div class="layui-input-block">
                <input class="layui-input" type="text" name="receiptMoney" value="${receipt.receiptMoney!}" lay-verify="required" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">尾款金额</label>
            <div class="layui-input-block">
                <input class="layui-input" type="text" name="finalPayment" value="${receipt.finalPayment!}" lay-verify="required" />
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button id="submitButton" class="layui-btn" lay-submit lay-filter="*">保存</button>
                <button type="button" class="layui-btn layui-btn-primary" onclick="closeAll()">取消</button>
            </div>
        </div>
    </form>
</div>
<script src="${ctxPath!}/jquery/jquery.min.js"></script>
<script src="${ctxPath!}/layui/layui.js"></script>
<script src="${ctxPath!}/jqgrid/jquery.jqGrid.minffe4.js?0820"></script>
<script src="${ctxPath!}/jqgrid/myjqGrid.js?v=1.0.1"></script>
<script type="text/javascript">
    layui.use(['form','layer','laydate'], function(){
        var form = layui.form;
        var layer=layui.layer;
        var laydate=layui.laydate;
        form.on('submit(*)', function(data){

            $.post($("#receiptForm").attr("action"), $("#receiptForm").serialize(), function(data){
                if(data.status == 200){
                    layer.alert(data.msg, {
                        icon: 1,
                        skin: 'layer-ext-moon'
                    },function () {
                        parent.myJqGrid.reloadGrid({});
                        parent.layer.closeAll();
                    });
                }else{
                    layer.alert(data.msg, {
                        icon: 2,
                        skin: 'layer-ext-moon'
                    });
                }
            });
            return false; //阻止表单跳转。
        });

        //日期显示
        laydate.render({
            elem : '#receiptDate'
        });
    });


    function closeAll() {
        parent.layer.closeAll();
    }
</script>
</body>
</html>